package cn.tedu.spring.dibase;

import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class BookTest {
    /**
     * 方式1：类型初始化属性
     */
    @Test
    public void setTest(){
        Book book=new Book();
        book.setBookAuthor("罗贯中");
        book.setBookName("红楼梦");
        book.run();
    }
    /**
     * 方式2：构造器初始化属性
     */
    @Test
    public void consTest(){
        Book book=new Book("西游记","吴承恩");
        book.run();
    }
    /**
     * 方式3：spring注入初始化属性
     */
    @Test
    public void springSetTest(){
        ApplicationContext context=new ClassPathXmlApplicationContext("bean-di.xml");
        Book book=(Book) context.getBean("book2",Book.class);
        book.run();
    }
}
